package com.wanmei.controller.order;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmei.pojo.Address;
import com.wanmei.pojo.User;
import com.wanmei.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
@Controller
@RequestMapping("order")
public class AddressListController {
    @Autowired
    private AddressService addressService;


    /**
     * 地址列表以及模糊查询
     * @param pageNum
     * @param likevalue
     * @return
     */
    @RequestMapping("addressListView")
    public ModelAndView findAddressByName(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, String likevalue) {

        System.out.println(likevalue);
        PageHelper.startPage(pageNum, 20);
        List<User> list = addressService.selectAddressByName(likevalue);
        PageInfo pageInfo = new PageInfo(list);
        System.out.println("查询的为："+list);
        ModelAndView model = new ModelAndView();
        model.addObject("likevalue", likevalue);
        model.addObject("pageInfo", pageInfo);
        model.setViewName("order/addressList");
        return model;
    }

}
